package com.dmzc.linkedlist;

//1
public class ReverseLinkedList1 {
    public static void main(String[] args) {
        //填充实验数据
        ListNode head = new ListNode(1);
        ListNode tail = head;
        tail = tail.next = new ListNode(2);
        tail = tail.next = new ListNode(3);
        tail = tail.next = new ListNode(4);
        tail = tail.next = new ListNode(5);
        head.show();
        ListNode prev = null;
        ListNode curr = head;
        ListNode temp = null;
        //反转单链表
        while (curr != null) {
            temp = curr.next;
            curr.next = prev;
            prev = curr;
            curr = temp;
        }
        if (prev != null) {
            prev.show();
        }

    }
}